Alex Brasch

Reference

Original Question

I am attempting to use the R package tigris within an R tool, in order to retrieve geographies using the Census API. The attached R code (saved as txt to allow upload) works as expected in RStudio. Note that tigris is not a package included in the Predictive Analytics RInstaller, but the package is correctly installed and available to Alteryx. Running the R tool produces the following error: The Designer x64 reported: InboundNamedPipe GetOverlappedResults: The pipe has been ended.

Note that on occasion, the error message also includes “You have found a bug. Replicate, then let us know. We shall fix it soon.” I opened a case, but was told that since the package is not part of the Predictive Analytics RInstaller that it is very unlikely the Dev team would address, so the case was closed.

Any advice on the potential issue would be helpful.

Solution by PaulNo

Huge thanks to PaulNo for assistance in finding a workable solution!

See the comments and solution in the R tigris package Inbound Pipe Error - Alteryx Community Solution post, and detailed in the code example below.

Code Example

Load required packages.

sf to geojson

By default, tigris returns sf (simple feature) objects, which is not a useable object type in Alteryx workflows outside of the R tool, because Alteryx Designer uses data-frame-like structures in its data streams. Therefore, we need to convert the sf object to a data frame.

Use the geojsonsf package to convert the sf geometry to a geojson vector; then convert the geojson vector to a data frame.

Remove the original sf geometry and join the original attribute data to the new data frame.

In Alteryx, write out to an output anchor; then use a Select tool to convert geometry to a spatial object.

 

A work by Alex Brasch